package com.tanhua.model.vo;

import com.tanhua.model.domain.Announcement;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.text.SimpleDateFormat;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class AnnouncementVo implements Serializable {   //公告
    private Long id;
    private String title;
    private String description;     //公告内容
    private String createDate;  //时间

    public static AnnouncementVo init(Announcement announcement) {
        AnnouncementVo vo = new AnnouncementVo();
        BeanUtils.copyProperties(announcement,vo);
        vo.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(announcement.getCreated()));
        return vo;
    }
}